//
//  BigCell.m
//  iYouGou
//
//  Created by qianfeng on 15/9/17.
//  Copyright (c) 2015年 qianfeng. All rights reserved.
//

#import "BigCell.h"
#import "BrandCell.h"
#import "UIImageView+AFNetworking.h"
#import "BrandView.h"
#import "ListController.h"
@implementation BigCell


- (void)setUrlString:(NSString *)urlString
{
    _urlString = urlString;
     [_ScollectionView registerNib:[UINib nibWithNibName:@"BrandView" bundle:nil] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader        withReuseIdentifier:@"BrandView"];
        
    
    
}



-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
   
    return _dataArry.count;
}

-(UICollectionViewCell*)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    BrandCell*cell=[collectionView dequeueReusableCellWithReuseIdentifier:@"BrandCell" forIndexPath:indexPath];
    NSDictionary*dic=_dataArry[indexPath.item];
    [cell.icon setImageWithURL:[NSURL URLWithString:dic[@"pic"]]]
    ;
    cell.logoLbl.text=dic[@"name"];
    return cell;
}

-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{

    return CGSizeMake((self.ScollectionView.frame.size.width-2)/3, (self.ScollectionView.frame.size.width-2)/3);

}

-(UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
    UICollectionReusableView*reusableView=nil;
    if ([kind isEqualToString:UICollectionElementKindSectionHeader]) {
        BrandView*brand=[collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"BrandView" forIndexPath:indexPath];
        [brand.imgView setImageWithURL:[NSURL URLWithString:_iconStr]];
        reusableView=brand;
    }
    return reusableView;
}
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section
{
    return CGSizeMake(self.ScollectionView.frame.size.width, 120);
    
}


-(BOOL)collectionView:(UICollectionView *)collectionView shouldSelectItemAtIndexPath:(NSIndexPath *)indexPath
{

    NSDictionary*dic=_dataArry[indexPath.row];
    ITEM*item=[[ITEM alloc]init];
    item.name=dic[@"name"];
    item.itemId=dic[@"id"];
    self.myBlock(item);
    return NO;
}



@end
